home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1995 May / cd Ware (Juegos) Epimundo.iso / DOS / C / PROXY.ZIP / FINANCE.PRX < prev    next >
Encoding:
Text File  |  1991-11-01  |  498 b   |  18 lines

  1. // state components:
  2.  
  3. // cashonhand: integer
  4. // inc: map(string,integer)
  5. // exp: map(string,integer)
  6.  
  7. receive(amount,source) {cashonhand=cashonhand+amount;
  8.           inc[source]=inc[source,0]+amount;
  9.           return "ok";};
  10. spend(amount,reason) {if(amount>cashonhand) return "Insufficient funds";
  11.          cashonhand=cashonhand-amount;
  12.          exp[reason]=exp[reason,0]+amount;
  13.          return "ok";};
  14. totalrec(source) {return inc[source,0];};
  15. totalspent(reason) {return exp[reason,0];};
  16. cashonhand=100;
  17. end
  18.